home *** CD-ROM | disk | FTP | other *** search
/ PC Action 1997 January / PCA0197.ISO / demos / ambe / roxy / roxy.dxr / 00676_overflow handlers.ls < prev    next >
Encoding:
Text File  |  1996-10-28  |  11.9 KB  |  387 lines

  1. on toggleHorsepower desiredSetting
  2.   global gHorsepower, oStoryteller
  3.   if getPos([#low, #high], desiredSetting) = 0 then
  4.     put "<!> Sorry, " & desiredSetting & " is not a valid suggestion for gHorsepower"
  5.     exit
  6.   end if
  7.   set gHorsepower to desiredSetting
  8.   setState(oStoryteller, #horsePower, desiredSetting)
  9.   grabberInit()
  10. end
  11.  
  12. on patchPalette
  13.   global oFixPal
  14.   if objectp(oFixPal) then
  15.     oFixPal(mPatchIt)
  16.   end if
  17. end
  18.  
  19. on forcePalette palName
  20.   global oPuppeteer, gCurrentPalette
  21.   puppetPalette(palName, 60)
  22.   set gCurrentPalette to #changeMe
  23.   patchPalette()
  24. end
  25.  
  26. on loadMultiframes whichOnes
  27.   global oPuppeteer
  28.   set theFrames to getaProp(the lsMultiframes of oPuppeteer, whichOnes)
  29.   if listp(theFrames) then
  30.     repeat with i in theFrames
  31.       preLoadCast(i)
  32.     end repeat
  33.   else
  34.     alert("Hey! There's no such list in lsMultiframes!")
  35.   end if
  36. end
  37.  
  38. on purgeMultiframes whichOnes
  39.   global oPuppeteer
  40.   set theFrames to getaProp(the lsMultiframes of oPuppeteer, whichOnes)
  41.   if listp(theFrames) then
  42.     repeat with i in theFrames
  43.       unLoadCast(i)
  44.     end repeat
  45.   else
  46.     alert("Hey! There's no such list in lsMultiframes!")
  47.   end if
  48. end
  49.  
  50. on gammaFade upOrDown, howFast, optionSwitch
  51.   global gCPU, gFadeStash, oPuppeteer, domainIsReady, oStoryteller, gVidViz
  52.   if gCPU = #PC then
  53.     if upOrDown = #down then
  54.       set domainIsReady to 0
  55.       set gFadeStash to []
  56.       repeat with i = 1 to 48
  57.         append(gFadeStash, the loc of sprite i)
  58.         if getPos([44, 45, 47, 48], i) = 0 then
  59.           set the loc of sprite i to point(-1000, -1000)
  60.         end if
  61.         if (i = 44) or (i = 45) then
  62.           setAt(gFadeStash, i, the visible of sprite i)
  63.           set the visible of sprite i to 0
  64.         end if
  65.       end repeat
  66.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #fadeIn))
  67.       updateStage()
  68.     end if
  69.     if upOrDown = #up then
  70.       set movieSprite to 45
  71.       if listp(gFadeStash) then
  72.         repeat with i = 1 to 48
  73.           if getPos([44, 45, 47, 48], i) = 0 then
  74.             set the loc of sprite i to getAt(gFadeStash, i)
  75.           end if
  76.         end repeat
  77.       end if
  78.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #fadeIn))
  79.       if getState(oStoryteller, #currentLocation) = #garageEscape then
  80.         set the loc of sprite 44 to point(-1000, -1000)
  81.       end if
  82.       set creditsLoc to the loc of sprite 45
  83.       set the loc of sprite 45 to point(-1000, -1000)
  84.       updateStage()
  85.       set the loc of sprite 45 to creditsLoc
  86.       if listp(gFadeStash) then
  87.         if optionSwitch <> #resumeGame then
  88.           repeat with vNum in [44, 45]
  89.             set the visible of sprite vNum to getAt(gFadeStash, vNum)
  90.           end repeat
  91.         else
  92.           set the visible of sprite 44 to getAt(gVidViz, 1)
  93.           set the visible of sprite 45 to getAt(gVidViz, 2)
  94.           set the movieTime of sprite 45 to getAt(gVidViz, 3)
  95.         end if
  96.         if the keyDownScript = EMPTY then
  97.           set domainIsReady to 1
  98.         end if
  99.       end if
  100.     end if
  101.     if upOrDown = #clearStage then
  102.       set gFadeStash to #None
  103.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #fadeIn))
  104.       updateStage()
  105.     end if
  106.   else
  107.     set speedCodes to [#glacial: "4", #slow: "18", #fast: "36", #instant: "100"]
  108.     set mySpeed to getaProp(speedCodes, howFast)
  109.     if voidp(mySpeed) then
  110.       set mySpeed to getProp(speedCodes, #fast)
  111.     end if
  112.     if upOrDown = #down then
  113.       MonitorFade("down", mySpeed)
  114.     else
  115.       updateStage()
  116.       MonitorFade("up", mySpeed)
  117.     end if
  118.   end if
  119. end
  120.  
  121. on fadeTest
  122.   gammaFade(#down)
  123.   wait(15)
  124.   gammaFade(#up, #glacial)
  125. end
  126.  
  127. on setColor howManybits
  128.   set the colorDepth to howManybits
  129.   if the colorDepth <> howManybits then
  130.     put "Sorry, Director sez the colorDepth is " & the colorDepth & " bits.."
  131.   else
  132.     put "OK, we did it.."
  133.   end if
  134. end
  135.  
  136. on peekAlert
  137.   global oStoryteller, oPuppeteer, gPeekAlertEnabled
  138.   if (gPeekAlertEnabled = 0) or (getState(oStoryteller, #playerHasPeekUnit) = 0) then
  139.     exit
  140.   end if
  141.   set colorGraphic to getAt(getProp(the lsInventoryData of oPuppeteer, #PeekUnit), 1)
  142.   set highGlowGraphic to getAt(getProp(the lsInventoryData of oPuppeteer, #PeekUnit), 3)
  143.   set lowGlowGraphic to getAt(getProp(the lsInventoryData of oPuppeteer, #PeekUnit), 2)
  144.   set oldPeekGraphic to the castNum of sprite 7
  145.   if oldPeekGraphic = colorGraphic then
  146.     set lowGlowGraphic to colorGraphic
  147.   end if
  148.   set bigGlow to 1
  149.   repeat with i = 1 to 12
  150.     set startTix to the ticks
  151.     repeat while the ticks < (startTix + 5)
  152.       updateStage()
  153.     end repeat
  154.     if bigGlow = 1 then
  155.       set the castNum of sprite 7 to highGlowGraphic
  156.     else
  157.       set the castNum of sprite 7 to lowGlowGraphic
  158.     end if
  159.     updateStage()
  160.     set bigGlow to not bigGlow
  161.   end repeat
  162.   set the castNum of sprite 7 to oldPeekGraphic
  163.   updateStage()
  164. end
  165.  
  166. on setScanTime howManyMinutes
  167.   global gScanFinish
  168.   set gScanFinish to the ticks + (howManyMinutes * 3600)
  169.   setState(oStoryteller, #PeekDisplay, value("#goodScan" & howManyMinutes & "min"))
  170.   setState(oStoryteller, #PKscanStatus, value("#Wait" & howManyMinutes & "min"))
  171.   peekAlert()
  172. end
  173.  
  174. on pyramidSpeaks
  175.   global oPuppeteer, oStoryteller
  176.   cursorOff()
  177.   set remainingMessages to getProp(the lsStateData of oStoryteller, #pyramidMessagesRemaining)
  178.   set messagesStack to getProp(the lsMultiframes of oPuppeteer, #PyramidMsg)
  179.   if count(remainingMessages) > 0 then
  180.     set helpTest to getAt(remainingMessages, 1)
  181.     if helpTest = #helpMe then
  182.       set myAnswer to 6
  183.       deleteAt(remainingMessages, 1)
  184.     else
  185.       set msgPosition to random(count(remainingMessages))
  186.       set myAnswer to getAt(remainingMessages, msgPosition)
  187.       deleteAt(remainingMessages, msgPosition)
  188.       if count(remainingMessages) = 0 then
  189.         append(remainingMessages, #helpMe)
  190.       end if
  191.     end if
  192.   else
  193.     set myAnswer to random(5)
  194.     if myAnswer = 5 then
  195.       if random(3) = 3 then
  196.         set myAnswer to 6
  197.       end if
  198.     end if
  199.   end if
  200.   set msgSprite to #None
  201.   repeat with i = 10 to 48
  202.     if getPos(messagesStack, the castNum of sprite i) then
  203.       set msgSprite to i
  204.       exit repeat
  205.     end if
  206.   end repeat
  207.   if msgSprite = #None then
  208.     alert("pyramidSpeaks: Yikes.. Couldn't find the message-sprite")
  209.     exit
  210.   end if
  211.   set the castNum of sprite msgSprite to getAt(messagesStack, myAnswer + 1)
  212.   do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #fadeIn))
  213.   soundEffect(#pyramidGurgle)
  214.   wait(25)
  215.   updateStage()
  216. end
  217.  
  218. on togglePreloading
  219.   global gPreloading
  220.   set gPreloading to not gPreloading
  221.   unLoadCast()
  222.   if gPreloading then
  223.   else
  224.   end if
  225. end
  226.  
  227. on toggleTransitions qualityDesired
  228.   global gStopTransitions, oPuppeteer, gTransQuality
  229.   set gTransQuality to qualityDesired
  230.   if qualityDesired = #None then
  231.     set gStopTransitions to 1
  232.   else
  233.     set gStopTransitions to 0
  234.   end if
  235.   if qualityDesired = #Better then
  236.     setProp(the lsMachineProfile of oPuppeteer, #transitions, [#turnRight: "02,1,16,TRUE", #turnLeft: "01,1,16,TRUE", #forward: "09,1,8,TRUE", #lookAt: "09,1,8,TRUE", #backOff: "10,1,8,TRUE", #lookUp: "03,1,16,TRUE", #lookDown: "04,1,16,TRUE", #fadeIn: "50,2,8,TRUE", #slowMontage: "50,3,8,TRUE", #nextPage: "2,2,32,TRUE", #prevPage: "1,2,32,TRUE"])
  237.   end if
  238.   if qualityDesired = #Best then
  239.     setProp(the lsMachineProfile of oPuppeteer, #transitions, [#turnRight: "02,1,16,TRUE", #turnLeft: "01,1,16,TRUE", #forward: "26,2,0,TRUE", #lookAt: "26,2,0,TRUE", #backOff: "26,2,0,TRUE", #lookUp: "03,1,16,TRUE", #lookDown: "04,1,16,TRUE", #fadeIn: "26,2,0,TRUE", #slowMontage: "26,3,0,TRUE", #nextPage: "2,2,16,TRUE", #prevPage: "1,2,16,TRUE"])
  240.   end if
  241. end
  242.  
  243. on toggleBitDepth
  244.   global g16bit
  245.   if g16bit then
  246.     set the colorDepth to 8
  247.     if the colorDepth = 8 then
  248.       set g16bit to 0
  249.     else
  250.       alert("Couldn't set the colordepth to 8-bit.. (Check the Monitors control panel for this monitor)")
  251.     end if
  252.   else
  253.     set the colorDepth to 16
  254.     if the colorDepth = 16 then
  255.       set g16bit to 1
  256.     else
  257.       alert("Couldn't set the colordepth to 16-bit.. (Check the Monitors control panel for this monitor)")
  258.     end if
  259.   end if
  260.   if g16bit then
  261.   else
  262.   end if
  263. end
  264.  
  265. on selectiveUpdate castList
  266.   global oPuppeteer, oStoryteller
  267.   set castUpdates to []
  268.   set spotUpdates to []
  269.   set match to #None
  270.   repeat with testString in castList
  271.     repeat with candidate in the lsOnstage of oPuppeteer
  272.       if getProp(candidate, #castName) = testString then
  273.         set match to candidate
  274.         put RETURN & "match = " & match
  275.         exit repeat
  276.       end if
  277.     end repeat
  278.     if match <> #None then
  279.       append(lsUpdates, match)
  280.       set match to #None
  281.       next repeat
  282.     end if
  283.     repeat with candidate in the lsAllHotspots of oPuppeteer
  284.       if getAt(getAt(candidate, 3), 1) = testString then
  285.         set match to candidate
  286.         put RETURN & "match = " & match
  287.         exit repeat
  288.       end if
  289.     end repeat
  290.     if match = #None then
  291.       alert("No match for string: '" & testString & "'")
  292.       next repeat
  293.     end if
  294.     append(lsUpdates, match)
  295.     set match to #None
  296.   end repeat
  297.   put RETURN & ">> FINAL LIST <<"
  298.   put castUpdates
  299. end
  300.  
  301. on changePal startCast, finishCast, newPalette
  302.   set newPaletteNumber to the number of member newPalette
  303.   repeat with i = startCast to finishCast
  304.     if the castType of cast i = #bitmap then
  305.       set the palette of cast i to newPaletteNumber
  306.       next repeat
  307.     end if
  308.     put the name of cast i & " is not a #bitmap castmember."
  309.   end repeat
  310. end
  311.  
  312. on grabberInit
  313.   global oGrabber, gRippleSize, gCPU, gHorsepower
  314.   set totalRAM to the memorysize / 1024
  315.   if (totalRAM >= 8000) and (gHorsepower <> #low) then
  316.     preLoadCast(2428, 2451)
  317.     set gRippleSize to #large
  318.   else
  319.     if totalRAM >= 6000 then
  320.       preLoadCast(2453, 2472)
  321.       set gRippleSize to #small
  322.     else
  323.       return #lowRAM
  324.       exit
  325.     end if
  326.   end if
  327.   return #OK
  328. end
  329.  
  330. on ripple
  331.   global oGrabber, gLastRipple, gRippleSize, gOriginPoint
  332.   if the ticks < (gLastRipple + (3 * 60)) then
  333.     exit
  334.   end if
  335.   if voidp(gRippleSize) then
  336.     set rippleStatus to grabberInit()
  337.     put "rippleStatus = " & rippleStatus
  338.     if rippleStatus <> #OK then
  339.       exit
  340.     end if
  341.   end if
  342.   set rippleSprite to 37
  343.   puppetSprite(rippleSprite, 1)
  344.   set the ink of sprite rippleSprite to 9
  345.   if gRippleSize = #small then
  346.     set firstCastPos to 2453
  347.     set lastCastPos to 2471
  348.     set grabWidth to 96
  349.     set grabHeight to 96
  350.     set rippleTempo to 2
  351.   else
  352.     set firstCastPos to 2428
  353.     set lastCastPos to 2450
  354.     set grabWidth to 160
  355.     set grabHeight to 170
  356.     set rippleTempo to 1
  357.   end if
  358.   set clipRegion to rect(the stageLeft + 112, the stageTop + 80, the stageLeft + 534, the stageTop + 356)
  359.   set leftOffset to random(the right of clipRegion - the left of clipRegion - (grabWidth + 2))
  360.   set leftEdge to the left of clipRegion + leftOffset
  361.   set topOffset to random(the bottom of clipRegion - the top of clipRegion - (grabWidth - 2))
  362.   set topEdge to the top of clipRegion + topOffset
  363.   set errCode to ScreenToClipboard(leftEdge, topEdge, leftEdge + grabWidth, topEdge + grabHeight)
  364.   if errCode = "OK" then
  365.     alert("errcode = " & errCode)
  366.     exit
  367.   end if
  368.   set leftEdge to leftEdge - the stageLeft
  369.   set topEdge to topEdge - the stageTop
  370.   set the loc of sprite rippleSprite to point(leftEdge + (grabWidth / 2), topEdge + (grabHeight / 2))
  371.   set the loc of sprite rippleSprite to the loc of sprite rippleSprite + point(1, 1)
  372.   pasteClipBoardInto(member firstCastPos)
  373.   set the castNum of sprite rippleSprite to firstCastPos
  374.   set newPos to firstCastPos + 2
  375.   updateStage()
  376.   repeat while newPos <= lastCastPos
  377.     wait(rippleTempo)
  378.     move(cast (newPos - 2), newPos)
  379.     set the castNum of sprite rippleSprite to newPos
  380.     set newPos to newPos + 2
  381.     updateStage()
  382.   end repeat
  383.   move(cast lastCastPos, firstCastPos)
  384.   set the loc of sprite rippleSprite to point(-1000, -1000) + gOriginPoint
  385.   set gLastRipple to the ticks
  386. end
  387.